package com.cms.web.pending;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cms.biz.pending.CMSPendingServiceMgr;
import com.persistence.qxgl.beans.SYSUser;
import com.web.BaseController;

import com.efounder.builder.base.data.EFDataSet;
import com.efounder.eai.data.JParamObject;
import com.efounder.eai.data.JResponseObject;

/** 
 * 评审合同控制器
 * 
 * @author ES
 * @version 1.0
 */
@Controller
@RequestMapping(value="/cmsPendingFlowControllerController")
public class PendingFlowController extends BaseController{
	@Autowired
	private                     CMSPendingServiceMgr                               pendingService;

	@Autowired
	public                               HttpSession                                      session;
	
	/**
	 * 生产申请单
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/reloadPendingFlow")
	public String pendingFlow(Model model) throws Exception {	
		SYSUser                 user = (SYSUser) session.getAttribute("contextUser");
		JResponseObject           RO = null;
		JParamObject              PO = JParamObject.Create();
		
		PO.SetValueByParamName("USER_ID", user.getUSER_ID());
		PO.SetValueByParamName("USER_ORGID", user.getUSER_ORGID());
		RO = pendingService.loadPendingFlow(PO);
		if(RO != null) {
			model.addAttribute("pendFlowData", RO.getResponseObject().toString());
		}
		
		return "/cms/pending/pendingFlow";
	}
	
	/**
	 * 生产申请单
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/reloadDepartmentComfire")
	public String reloadDepartmentComfire(Model model) throws Exception {	
		SYSUser                 user = (SYSUser) session.getAttribute("contextUser");
		JResponseObject           RO = null;
		JParamObject              PO = JParamObject.Create();
		
		PO.SetValueByParamName("USER_ID", user.getUSER_ID());
		PO.SetValueByParamName("USER_ORGID", user.getUSER_ORGID());
		RO = pendingService.loadDepartmentConfirmPendingFlow(PO);
		if(RO != null) {
			model.addAttribute("bmqrDataset", (EFDataSet) RO.getResponseObject());
		}
		
		return "/cms/pending/departmentConfirm";
	}
	
	/**
	 * 公告通知
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/reloadNiticeMessage")
	public String reloadNiticeMessage(Model model) throws Exception {	
		SYSUser                 user = (SYSUser) session.getAttribute("contextUser");
		JResponseObject           RO = null;
		JParamObject              PO = JParamObject.Create();
		
		PO.SetValueByParamName("USER_ID", user.getUSER_ID());
		PO.SetValueByParamName("USER_ORGID", user.getUSER_ORGID());
		PO.SetValueByParamName("BILL_ORDER", "F_FBRQ desc limit 10");
		PO.SetValueByParamName("BILL_WHERE", "F_GGZT = '1'");
		PO.SetValueByParamName("tableName", "TZGGZD");
		RO = pendingService.loadNiticeMessage(PO);
		if(RO != null) {
			model.addAttribute("noticeMessageDataSet", (EFDataSet) RO.getResponseObject());
		}
		
		return "/cms/pending/noticeMessage";
	}
}
